import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';

export default (appInfo: EggAppInfo) => {
  const config = {} as PowerPartial<EggAppConfig>;

  config.keys = appInfo.name + '_zhushenxiu';

  // add your egg config in here
  config.middleware = [];

  // add your special config in here
  const bizConfig = {
    sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`,
  };

  // 跨域
  config.security = {
    csrf: {
      enable: false,
    },
    domainWhiteList: ['*'],//允许访问接口的白名单，例如：http://localhost:8080 *表示均可访问
  };

  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
  };

  config.jwt = {
    secret: "zhushenxiu", //密钥
    // ignore: [/^\/user\/login/], // 哪些请求不需要认证
  };

  config.mysql = {
    client: {
      // 域名/IP
      host: '127.0.0.1',
      // 端口
      port: '3306',
      // 用户名
      user: 'root',
      // 密码
      password: 'root',
      // 数据库
      database: 'pokenman',
    },
  };

  // 文件上传格式
  config.multipart = {
    mode: 'file',
  };

  return {
    ...config,
    ...bizConfig,
  };
};
